#include "bubblesort.hpp"

void bbsort(vector<int> &a)
{
    // bool swapped;
    int last_swapped = a.size() - 1;
    do {
        int index = 0;
        for (int i = 0; i < last_swapped; i++) {
            if (a[i] > a[i+1]) {
                // swap a[i] and a[i+1]
                int tmp = a[i+1];
                a[i+1] = a[i];
                a[i] = tmp;
                index = i;
            }
        }
        last_swapped = index;
    } while (last_swapped > 0);
}
